using AiQiuQuan.Sport.Model.Models;
using AiQiuQuan.Sport.Core;
using AiQiuQuan.Sport.WebApi.Services;
using Microsoft.AspNetCore.Mvc;

namespace AiQiuQuan.Sport.WebApi.Controllers
{
    /// <summary>
    /// 平台教练管理
    /// </summary>
    public class PlatformCoacherController : PcApiController
    {
        private readonly ICoacherService _coacherService;

        /// <summary>
        /// 教练管理
        /// </summary>
        public PlatformCoacherController(
            ICoacherService coacherService
            )
        {
            _coacherService = coacherService;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="id">教练ID</param>
        [HttpGet("get")]
        public async Task<UnaryResult<CoacherDto>> GetAsync(Guid id)
        {
            var result = await _coacherService.GetAsync(id, true);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 分页请求
        /// </summary>
        [HttpPost("pagelist")]
        public async Task<UnaryResult<PageResult<CoacherDto>>> PageListAsync(CoacherPageRequestDto request)
        {
            request.IsPlatform = true;
            var result = await _coacherService.PageListAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 平台分页请求
        /// </summary>
        [HttpPost("pagelist_query")]
        public async Task<UnaryResult<PageResult<CoacherDto>>> QueryPageListAsync(CoacherRequestDto request)
        {
            request.IsPlatform = true;
            var result = await _coacherService.QueryPageListAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 新增
        /// </summary>
        [HttpPost("add")]
        public async Task<UnaryResult> AddAsync(CoacherAddDto model)
        {
            model.IsPlatform = true;
            var result = await _coacherService.AddAsync(model);
            return result;
        }

        /// <summary>
        /// 修改
        /// </summary>
        [HttpPost("update")]
        public async Task<UnaryResult> UpdateAsync(CoacherUpdateDto model)
        {
            var result = await _coacherService.UpdateAsync(model);
            return result;
        }

        /// <summary>
        /// 删除
        /// </summary>
        [HttpPost("delete")]
        public async Task<UnaryResult> DeleteAsync(Guid id)
        {
            var result = await _coacherService.DeleteAsync(id);
            return result;
        }

        /// <summary>
        /// 获取私教学生分页列表
        /// </summary>
        [HttpPost("pagelist_personal_student")]
        public async Task<UnaryResult<PageResult<CoacherStudentDto>>> GetCoacherStudentPageList(CoacherStudentPageRequestDto request)
        {
            var result = await _coacherService.GetCoacherStudentPageList(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 教练场馆列表
        /// </summary>
        /// <param name="coacherUserId">教练用户ID</param>
        [HttpGet("list_venue")]
        public async Task<UnaryResult<List<CoacherVenueDto>>> GetCoacherVenueListAsync(Guid coacherUserId)
        {
            var result = await _coacherService.GetCoacherVenueListAsync(coacherUserId);
            return UnaryResult.Succeed(result);
        }
    }
}
